﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace VRacer.Packets
{
    public class PlayerPositionPacket : PlayerPacket
    {
        protected Position _position = new Position();

        public PlayerPositionPacket()
            : base(PacketType.PlayerPosition)
        {

        }

        public PlayerPositionPacket(PlayerBase player)
            : this()
        {
            _id = player.ID;
            _position = new Position((int)player.Position.X, (int)player.Position.Y);
        }

        public Position Position
        {
            get { return _position; }
            set { _position = value; }
        }

        public override void Read(System.IO.BinaryReader reader)
        {
            base.Read(reader);

            _id = reader.ReadInt32();
            _position.X = reader.ReadInt32();
            _position.Y = reader.ReadInt32();
        }

        public override void Write(System.IO.BinaryWriter writer)
        {
            base.Write(writer);

            writer.Write(_id);
            writer.Write(_position.X);
            writer.Write(_position.Y);
        }
    }
}
